#include<cstdio>
int a[2001][2001]; 
int n,m;
int h[2001][2001];
int left[2001],right[2001]; 
int max(int s,int t)
{
    if(s<t) return t;
    else return s;
}
void read()
{
    int i,j,k,t;
	scanf("%d",&t);
    while(t--)
	{
		scanf("%d%d",&n,&m);
		for(i=1;i<=n;i++)
            for(j=1;j<=m;j++)
			{
				char ch;
                scanf("%c",&ch);
				while((ch!='F')&&(ch!='R'))scanf("%c",&ch);
				if(ch=='R')a[i][j]=0;
				else a[i][j]=1;
			}
        for(i=1;i<=n;i++)
            for(j=1;j<=m;j++)
                if(!a[i][j])
                    h[i][j]=0;
                else
                    h[i][j]=h[i-1][j]+1;
        int ans=0;
        for(i=1;i<=n;i++)
        {
            h[i][0]=h[i][m+1]=-1;
            for(j=1;j<=m;j++)
                left[j]=right[j]=j;
            for(j=1;j<=m;j++)
                while(h[i][j]<=h[i][left[j]-1])
					left[j]=left[left[j]-1];
            for(j=m;j>=1;j--)
                while(h[i][j]<=h[i][right[j]+1])
					right[j]=right[right[j]+1];
            for(j=1;j<=m;j++)
                if(h[i][j]>0)
                    ans=max(ans,(right[j]-left[j]+1)*h[i][j]);
        }
        printf("%d\n",ans*3);
	}
}
 
int main()
{
    read();
    return 0;
}


